<template>
  <div id="index" ref="appRef">
    <div class="bg">
      <dv-loading v-if="loading">Loading...</dv-loading>
      <div v-else class="host-body">
        <div class="d-top-time">
          <span class="text"
            >{{ dateYear }} &nbsp; {{ dateDay }} &nbsp; {{ dateWeek }}
          </span>
        </div>
        <div class="d-flex jc-center px-2 d-top">
          <div class="d-flex jc-center">
            <div class="title" />
          </div>
        </div>

        <div class="body-box">
          <div class="content-box">
            <div class="left">
              <div class="border">
                <left1 />
              </div>
              <div class="border">
                <left2 />
              </div>
              <div class="border">
                <left3 />
              </div>
            </div>
            <!-- 中间 -->
            <div class="center">
              <center />
            </div>
            <div class="right">
              <div class="border">
                <right1 />
              </div>
              <div class="border">
                <right2 />
              </div>
            </div>
          </div>
          <!-- end -->
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import drawMixin from '../utils/drawMixin'
import { formatTime } from '../utils/index.js'
import left1 from '@/components/echart/left1'
import left2 from '@/components/echart/left2'
import left3 from '@/components/echart/left3'
import right1 from '@/components/echart/right1'
import right2 from '@/components/echart/right2'
import center from '@/components/echart/center'

export default {
  components: {
    left1,
    left2,
    left3,
    right1,
    right2,
    center
  },
  mixins: [drawMixin],
  data() {
    return {
      timing: null,
      loading: true,
      dateDay: null,
      dateYear: null,
      dateWeek: null,
      weekday: [
        '星期日',
        '星期一',
        '星期二',
        '星期三',
        '星期四',
        '星期五',
        '星期六'
      ]
    }
  },
  mounted() {
    this.timeFn()
    this.cancelLoading()
  },
  beforeDestroy() {
    clearInterval(this.timing)
  },
  methods: {
    timeFn() {
      this.timing = setInterval(() => {
        this.dateDay = formatTime(new Date(), 'HH: mm: ss')
        this.dateYear = formatTime(new Date(), 'yyyy年MM月dd日')
        this.dateWeek = this.weekday[new Date().getDay()]
      }, 1000)
    },
    cancelLoading() {
      setTimeout(() => {
        this.loading = false
      }, 500)
    }
  }
}
</script>

<style lang="scss">
@import '../assets/scss/index.scss';
</style>
